package com.situ.mall.admin.config;



import com.situ.mall.admin.interceptor.LoginInterceptor;
import com.situ.mall.base.util.C;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


// 配置类
@Configuration
public class InterceptorConfiguration implements WebMvcConfigurer {

    // 添加拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns("/login", "/captcha",
                        "/js/**", "/css/**", "/images/**",
                        "/lib/**", "/page/**");
    }

    // 本地资源的配置
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler(C.UPLOAD_PATH_PREFIX + "**")
                .addResourceLocations(C.FILE + C.AVATAR_PATH)
                .addResourceLocations(C.FILE + C.PRODUCT_PATH)
                .addResourceLocations(C.FILE + C.BANNER_PATH);
    }

}
